package org.wxd.pg.demo.ctl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wxd.pg.demo.dao.mapper.UserMapper;
import org.wxd.pg.demo.dao.model.User;

@RestController
public class UserCtl {
    @Autowired
    private UserMapper userMapper;

    @RequestMapping("/user/{id}")
    public User of(@PathVariable("id") Integer id){
        return userMapper.of(id);
    }

    @RequestMapping("/user/p/{name}")
    public Boolean persist(@PathVariable("name") String name){
        userMapper.persist(new User(name));
        return Boolean.TRUE;
    }

}
